import { config } from 'dotenv';

config();

function getPublic() {
  let publicPath = process.env.PUBLIC_PATH || '/';
  if (publicPath.lastIndexOf('/') !== publicPath.length - 1) {
    publicPath += '/';
  }

  return publicPath;
}

export const PORT = process.env.VITE_EXPRESS_PORT || 8080;
export const IS_PROD = process.env.NODE_ENV === 'production';
export const PUBLIC_PATH = getPublic();

// 数据库配置
export const DB_CONFIG = {
  host: process.env.DB_HOST || 'localhost',
  port: Number(process.env.DB_PORT) || 3306,
  user: process.env.DB_USER || 'root',
  password: process.env.DB_PASSWORD || '',
  database: process.env.DB_NAME || 'hedgehog_roleplay',
};
